home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / GAMAXON / Bklaguer.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  2.1 KB  |  64 lines

  1. // Dynamic link library implementation of NeuroSolutions BackLaguerreAxon component 
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /********************************/
  6. /* Backpropagation of component */
  7.  
  8. __declspec(dllexport) void performBackGammaAxon(
  9.     DLLData *instance,    // Pointer to instance data (may be NULL)
  10.     DLLData *dualInstance,    // Pointer to the forward axons instance data (may be NULL)
  11.     NSFloat    *error,         // Pointer to the current error vector
  12.     int     rows,        // Number of rows of PEs in the layer
  13.     int     cols,        // Number of columns of PEs in the layer
  14.     NSFloat    *delayedError,     // Pointer to the error vector delayed by a user defined time step
  15.     int     taps,        // Number of memory taps specified by the user in the inspector
  16.     NSFloat    *data,         // Pointer to the layers of processing elements (PEs)
  17.     NSFloat    *gamma,            // Pointer to a vector of gamma coefficients, one for each PE
  18.     NSFloat    *gradient         // Pointer to the gamma gradient vector
  19.     )
  20. {
  21.     register int i,j,k,length=rows*cols;
  22.      NSFloat gain;
  23.  
  24.     for (i=0; i<length; i++) {
  25.         gain = (NSFloat)pow(1-pow(gamma[i], 2.0f), 0.5f);
  26.         for (j=taps-1; j>=0; j--) {
  27.             k = i + j*length;
  28.             if (j==0) {
  29.                 error[k] += gamma[i]*delayedError[k]/gain;
  30.                 error[k] *= gain;
  31.                 if (gradient)
  32.                     gradient[i] += data[k]*delayedError[k]/gain;
  33.             }
  34.             else {
  35.                 error[k] += gamma[i]*delayedError[k];
  36.                 error[k-length] += delayedError[k] - gamma[i]*error[k];
  37.                 if (gradient)
  38.                     gradient[i] += delayedError[k]*data[k] - error[k]*data[k-length];
  39.             }
  40.         }
  41.     }
  42. }
  43.  
  44. /******************************************/
  45. /* Management of instance data (OPTIONAL) */
  46. /*
  47. __declspec(dllexport) DLLData *allocBackGammaAxon(
  48.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  49.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  50.     int     rows,        // Number of rows of PEs in the layer
  51.     int     cols,        // Number of columns of PEs in the layer
  52.     int     taps        // Number of taps attached to each PE
  53.     )
  54. {
  55.     DLLData *instance = allocDLLInstance(oldInstance);
  56.     return instance;
  57. }
  58.  
  59. __declspec(dllexport) void freeBackGammaAxon(DLLData *instance)
  60. {
  61.     freeDLLInstance(instance);
  62. }
  63. */
  64.